package com.yupi.apiback.model.entity;

import cn.hutool.core.date.DatePattern;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 公共父类
 * @author yanghaifeng
 * @date 2024/1/18 11:24
 */
@Data
public class SuperModel implements Serializable {

    private static final long serialVersionUID = 1748087769430450878L;

    @TableId(type = IdType.AUTO)
    @ApiModelProperty("id")
    private Long id;

    @TableField(fill = FieldFill.INSERT)
    @ApiModelProperty("创建人")
    private String createBy;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    @ApiModelProperty("修改人")
    private String updateBy;

    @TableField(fill = FieldFill.INSERT)
    @ApiModelProperty("创建时间")
//    @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
    @JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN, timezone = "GMT+8")
    private LocalDateTime createTime;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    @ApiModelProperty("更新时间")
    // 自动将时间格式化展示给前端
    @JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN, timezone = "GMT+8")
    private LocalDateTime updateTime;

    @TableLogic
    @ApiModelProperty("是否删除")
    private Integer isDel;
}
